#define PAINT_EVENT      // 使用绘制事件来显示帧
#define DEPLOY_ANDROID   // 使用部署到Android的代码
// #define SEND_TEST		// 将视频帧发送给自己以测试程序是否正常
// #define DEBUG				// DEBUG

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "myvideosurface.h"
#include "debug.h"

#include <QList>
#include <QHostAddress>
#include <QCameraInfo>
#include <QScopedPointer>
#include <QVideoFrame>
#include <QPaintEvent>
#include <QImage>
#include <QScreen>
#include <QByteArray>
#include <QUdpSocket>

#include <QMainWindow>
#include <QVideoWidget>
#include <QAction>


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
        Q_OBJECT

    public:
        MainWindow(QWidget *parent = nullptr , QScreen *screen = nullptr);
        ~MainWindow();

    protected:
#ifdef PAINT_EVENT
        void paintEvent(QPaintEvent *event) override ;
#endif
    private:
        Ui::MainWindow *ui;
        QScreen *screen ;
        QList<QAction *> tooBarActions ;
        QHostAddress targetAddress ;
        QScopedPointer<QCamera> m_camera ;
        MyVideoSurface videoSurface ;
        QImage img ;
        QUdpSocket *sender ;
        QHostAddress receiverAddr ;
        int receiverPort ;
        float scalar ;
        bool paint ;
#ifdef DEBUG
        Debug *debug ;
#endif

        void setCamera(const QCameraInfo &cameraInfo) ;

    public slots :
        void updateCamera(QAction *action) ;
        void showVideoFrame(QVideoFrame frame) ;
        void parameterCommit() ;
        void isPaint() ;
        void readySend() ;
        void nonreadySend() ;
        void sendVideoFrame( QVideoFrame frame ) ;
#ifdef SEND_TEST
        void showByteArrayToImage( const QByteArray &barr ) ;
        void readPendingDatagrams() ;
#endif
};
#endif // MAINWINDOW_H
